#!/bin/bash

FILE=./config.xml
ENCRPT_EXEC=./to_uper

sed -n '/mysql/'p $FILE | \
	awk -F\> '{print $2}' | \
	awk  -F\< '{print $1}' > ./__tmp__1.dat

cnt__=0
dest_arr[0]=0
while read ln
do
	dest_arr[$cnt__]=`$ENCRPT_EXEC $ln`
	cnt__=`expr $cnt__ + 1`
done < ./__tmp__1.dat

sed -n '/mysql/=' $FILE > ./__tmp__1.dat

cnt__=0;
while read ln
do
	newstr="<mysql>${dest_arr[$cnt__]}<\/mysql>"
	#echo $newstr
	sed -i "$ln s/<mysql>.*<\/mysql>/$newstr/" $FILE
	let cnt__++;
done < ./__tmp__1.dat

#clean temp file
rm -rf ./__tmp__1.dat


